<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
	 String username = request.getParameter("username");
	 String password = request.getParameter("password");
	
	 if (username == null || password == null) {
	
	     out.print("Invalid paramters ");
	 }
	 else
	 {
		 
		 username = request.getParameter("username");
		 password = request.getParameter("password"); 
	 
	
		 // Here you put the check on the username and password
		 if (username.toLowerCase().trim().equals("abc") && password.toLowerCase().trim().equals("abc")) {
		     out.println("Welcome " + username + " <a href=\"restricted_page.jsp\">Back to main</a>");
		     
		     Cookie cookie= new Cookie("username", username);
			 response.addCookie(cookie);
			 
			 cookie= new Cookie("password", password);
			 response.addCookie(cookie);
			 
			 cookie= new Cookie("staticNum", "123456789");
			 response.addCookie(cookie);
			 
			 cookie= new Cookie("subDir", "for this only!" );
			 cookie.setPath("/cookie");
			 response.addCookie(cookie);
			 
		     //session.setAttribute("username", username);
		     //session.setAttribute("keypass", new Integer(30624700));
		 }
		else 
		    {
		     out.println("Invalid username and password");
		}
	}
%> 
</body>
</html>